package es.prodevelop.arport;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.TextView;
import es.prodevelop.arport.util.Utils;

/**
 * simple Activity for displaying information about a specific poi gets the
 * information about a poi from an intent
 */
public class PoiActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.poi);

		String id = getIntent().getExtras().getString("POI_ID");
		String poiName = "";
		String poiDesc = "";

		if (getIntent().getExtras().getBoolean("HERITAGE")) {
			for (PoiBean bean : Utils.getHeritageList()) {
				if (id == null || !id.equals(bean.getId())) {
					continue;
				}
				poiName = bean.getName();
				poiDesc = bean.getDescription();
				break;
			}
		} else if (getIntent().getExtras().getBoolean("LEISURE")) {
			for (PoiBean bean : Utils.getLeisureList()) {
				if (id == null || !id.equals(bean.getId())) {
					continue;
				}
				poiName = bean.getName();
				poiDesc = bean.getDescription();
				break;
			}
		}

		((TextView) findViewById(R.id.nameTextView)).setText(poiName);

		final String mimeType = "text/html";
		final String encoding = "UTF-8";
		WebView wv = (WebView) findViewById(R.id.webView);
		wv.loadDataWithBaseURL("file:///android_asset/", poiDesc, mimeType,
				encoding, null);
	}
}
